﻿using System;
using System.Linq.Expressions;

namespace VirtualTournaments.DataAccess.SqlServer.DataProxies
{
	internal sealed class UserDataProxy : Business.Users.User, IDataProxy<SqlServer.User>, Identifiable<SqlServer.User>
	{
		private SqlServer.User _dataObject;

		internal UserDataProxy(SqlServer.User dataObject)
			: base(dataObject.UserName, new PasswordProxy(dataObject.Md5Password), new Business.Players.Name(dataObject.Firstname, dataObject.Surname))
		{
			this._dataObject = dataObject;
		}

		#region IDataProxy<User> Members

		public SqlServer.User InnerDataObject
		{
			get { return this._dataObject; }
			set { this._dataObject = value; }
		}

		#endregion

		#region Identifiable<User> Members

		public Expression<Func<SqlServer.User, bool>> GetUniqueWhereExpression()
		{
			return user => user.UserId == InnerDataObject.UserId;
		}

		#endregion
	}
}
